# response message
class RET:

    PARAMERR            = "20100"
    PARAMMISSERR        = "20101"

    TOKENERR            = "20200"
    LOGINERR            = "20201"
    LOGINTYPEERR        = "13405"
    USERERR             = "20202"
    PERMISSIONERR       = "20203"
    USERREGISTEREDERR   = "20204"
    USERLOCKEDERR       = "20205"
    USERNICKNAMEERR     = "20206"
    ROLEERR             = "20207"
    SEXERR              = "20208"
    NICKNAMEEXERR       = "20209"

    DBERR               = "20300"
    NODATA              = "20301"
    DATAEXIST           = "20302"
    DATAERR             = "20303"

    PWDERR              = "20400"
    REQERR              = "20401"
    IPERR               = "20402"
    THIRDERR            = "20403"
    IOERR               = "20404"
    SERVERERR           = "20405"
    UNKOWNERR           = "20406"
    PHONEERR            = "20407"
    CHECKCODEERR        = "20408"
    PHONESENDSTATERR    = "20409"

    SMSERR              = "11403"
    SMSLIMITERR         = "11402"

error_map = {
    RET.PARAMERR              :  "参数错误",
    RET.PARAMMISSERR          :  "参数缺失",

    RET.TOKENERR              :  "用户未登录",
    RET.LOGINERR              :  "用户登录失败",
    RET.LOGINTYPEERR          :  "登录类型验证错误",
    RET.USERERR               :  "用户不存在或未激活",
    RET.USERREGISTEREDERR     :  "用户已经存在",
    RET.USERNICKNAMEERR       :  "昵称验证失败",
    RET.PERMISSIONERR         :  "用户权限错误",
    RET.ROLEERR               :  "角色信息解析失败",
    RET.NICKNAMEEXERR         :  "昵称已存在",

    RET.DBERR                 :  "数据库查询错误",
    RET.NODATA                :  "数据不存在",
    RET.DATAEXIST             :  "数据已存在",
    RET.DATAERR               :  "数据错误",

    RET.IPERR                 :  "IP受限",
    RET.PWDERR                :  "密码错误",
    RET.REQERR                :  "非法请求或请求次数受限",
    RET.THIRDERR              :  "第三方系统错误",
    RET.IOERR                 :  "文件读写错误",
    RET.SERVERERR             :  "内部错误",
    RET.UNKOWNERR             :  "未知错误",
    RET.PHONEERR              :  "手机号码验证失败",
    RET.PHONESENDSTATERR      :  "短信验证码发送状态检查失败",

    RET.SMSERR                :   "短信验证码失败",
    RET.SMSLIMITERR           :   "一分钟仅能发送一条"
}


# 正则
# 2018 年最新手机正则
REGEX_MOBILE = r"^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$"

# 身份证正则
REGEX_IDCARD = r"([1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx])|([1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx])$"

# 银行卡正则
REGEX_BANK_ACCOUNT = r"([3,4,5,6]{1})(\d{14,18})$"


# 常量
# 在线用户持续时间
ONLINE_LAST_MINUTES = 10
